<template>
	<view>
		<view v-if="(propData || null) != null && propData.length > 0" :class="'goods-spec-choose plugins-yxformplus'+yx_form_type">
			<view v-for="(item, key) in propData" :key="key" :class="'item '+(yx_form_type == 1 ? '' : 'flex-row')">
				<view v-if="yx_form_type == 0" class="title"><text v-if="item.is_must == 1" class="cr-red text-size-xs margin-right-sm">*</text><text v-else class="cr-white text-size-xs margin-right-sm">*</text>{{item.name}}</view>
				<view v-else class="title">{{item.name}}<text v-if="item.is_must == 1" class="cr-red text-size-xs margin-left-sm">*</text><text class="cr-999 text-size-xs margin-left-sm">{{item.tishi_text}}</text></view>
				<view :class="'spec '+(yx_form_type == 0 ? ('flex-1 '+((item.type == 5 || item.type == 2 || item.type == 9 || item.type == 10) ? 'spec2' : '')) : '')">
					<!--文本类-->
					<block v-if="item.type == 1">
						<input type="text" :placeholder="item.tishi_text || '请填写'+item.name" :name="'input_'+item.sid+'_'+item.type+'_'+item.id" :class="'form-item wh-auto yxformplus-item '+(yx_form_type == 1 ? 'margin-vertical-main' : '')" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :value="item.moren" :data-validation-message="((item.minlength == 0 && item.maxlength == 0) ? '请输入' : '')+item.name+(item.minlength > 0 ? '最少'+item.minlength+'个字符' : '')+(item.maxlength > 0 ? '最多'+item.maxlength+'个字符' : '')" @focus="check_user_login" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength">
					</block>
					<!--多行文本类-->
					<block v-if="item.type == 2">
						<textarea :placeholder="item.tishi_text || '请填写'+item.name" :name="'textarea_'+item.sid+'_'+item.type+'_'+item.id" :class="'form-item wh-auto yxformplus-item '+(yx_form_type == 1 ? 'margin-vertical-main' : '')" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :auto-height="true" :value="item.moren" :data-validation-message="((item.minlength == 0 && item.maxlength == 0) ? '请输入' : '')+item.name+(item.minlength > 0 ? '最少'+item.minlength+'个字符' : '')+(item.maxlength > 0 ? '最多'+item.maxlength+'个字符' : '')" @focus="check_user_login" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength" :style=""></textarea>
					</block>
					<!--整数类-->
					<block v-if="item.type == 3">
						<input type="number" :placeholder="item.tishi_text || '请填写'+item.name" :name="'input_'+item.sid+'_'+item.type+'_'+item.id" :class="'form-item wh-auto yxformplus-item '+(yx_form_type == 1 ? 'margin-vertical-main' : '')" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :value="item.moren" :data-validation-message="((item.minlength == 0 && item.maxlength == 0) ? '请输入' : '')+item.name+(item.minlength > 0 ? '最小'+item.minlength : '')+(item.maxlength > 0 ? '最大'+item.maxlength : '')" @focus="check_user_login" @blur="yxblur" @confirm="yxblur" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength">
					</block>
					<!--单选-->
					<block v-if="item.type == 4 && (item.danxuan || null != null)">
						<view class="uni-list">
							<radio-group @change="yxonclick" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<label class="yxradio" v-for="(items, indexs) in item.danxuan" :key="indexs">
									<radio :value="items.value" :checked="items.checked != ''" :color="theme_color" :name="'radio_'+item.sid+'_'+item.type+'_'+item.id" style="transform:scale(0.7);" />{{items.name}}
								</label>
							</radio-group>
						</view>
					</block>
					<!--多选-->
					<block v-if="item.type == 5 && (item.duoxuan || null != null)">
						<view class="uni-list">
							<checkbox-group @change="yxonclick" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<label class="yxcheckbox" v-for="(items, indexs) in item.duoxuan" :key="indexs">
									<checkbox :value="items.value" :checked="items.checked != ''" :color="theme_color" :name="'radio_'+item.sid+'_'+item.type+'_'+item.id" style="transform:scale(0.7);" />{{items.name}}
								</label>
							</checkbox-group>
						</view>
					</block>
					<!--下拉-->
					<block v-if="item.type == 6 && (item.xiala || null != null)">
						<view class="yxsection">
						    <picker :name="'select_'+item.sid+'_'+item.type+'_'+item.id" @change="yxselect" :value="yxxiala_value[key]" :range="item.xiala" range-key="name" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<view :class="'name ' + ((yxxiala_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{(yxxiala_value[key] == null) ? '请选择'+item.name : (((item.xiala[yxxiala_value[key]] || null) == null) ? item.default_value : item.xiala[yxxiala_value[key]]['name'])}}<text class="arrow-right cr-grey padding-left"></text></view>
						    </picker>
						</view>
					</block>
					<!--日期-->
					<block v-if="item.type == 7">
						<view class="yxsection">
							<picker mode="date" :value="(item.moren || null) != null ? item.moren : 0" @change="bindDateChange" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<view class="tj-input cr-grey">{{item.moren || '请选择'+item.name}}<text class="arrow-right cr-grey padding-left"></text></view>
							</picker>
						</view>
					</block>
					<!--时间-->
					<block v-if="item.type == 8">
						<view class="yxsection">
							<picker mode="time" :value="item.moren" @change="bindDateChange" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<view class="tj-input cr-grey">{{item.moren || '请选择'+item.name}}<text class="arrow-right cr-grey padding-left"></text></view>
							</picker>
						</view>
					</block>
					<!--附件-->
					<block v-if="item.type == 9 || item.type == 10">
						<view class="yxfile">
							<view class="form-upload-data fl">
							    <block v-if="(yxfile[key] || null) != null && yxfile[key].length > 0">
							        <view v-for="(items, ix) in yxfile[key]" :key="ix" class="picitem fl">
							            <text class="delete-icon" @tap="upload_delete_event" :data-index="key" :data-ix="ix">x</text>
										<block v-if="item.file_type == 'images'">
											<image :src="items" @tap="upload_show_event" :data-index="key" :data-ix="ix" mode="aspectFill" class="padding-xs dis-block"></image>
										</block>
							            <block v-else-if="item.file_type == 'video'">
											<video :src="items" :show-center-play-btn="true" :controls="false" :show-play-btn="false" :enable-progress-gesture="false" :show-fullscreen-btn="false"></video>
										</block>
										<block v-else>
											<view class="wendangbox">{{item.name}}{{ix}}</view>
										</block>
							        </view>
							    </block>
							</view>
							<image v-if="(yxfile[key] || null) == null || yxfile[key].length < item.max_num" class="upload-icon" :src="common_static_url+'upload-icon.png'" mode="aspectFill" @tap="file_upload_event" :data-index="key" :data-file_type="item.file_type" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-max-number="item.max_num" :data-validation-message="item.name+'必须上传'"></image>
							<view class="c_b"> </view>
						</view>
					</block>
					<!--金钱货币-->
					<block v-if="item.type == 11">
						<input type="digit" :placeholder="item.tishi_text || '请填写'+item.name" :name="'input_'+item.sid+'_'+item.type+'_'+item.id" :class="'form-item wh-auto yxformplus-item '+(yx_form_type == 1 ? 'margin-vertical-main' : '')" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :value="item.moren" @focus="check_user_login" @blur="yxblur" @confirm="yxblur" :data-validation-message="((item.minlength == 0 && item.maxlength == 0) ? '请输入' : '')+item.name+(item.minlength > 0 ? '最小'+item.minlength+'' : '')+(item.maxlength > 0 ? '最大'+item.maxlength+'' : '')" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength">
					</block>
					<!--三级地址-->
					<block v-if="item.type == 12">
						<view class="select-address oh">
						    <view class="section fl">
						        <picker :name="'province_'+item.sid+'_'+item.type+'_'+item.id" @change="select_province_event" :value="(province_value[key] || null != null) ? province_value[key] : 0" :range="province_list[key]" range-key="name" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :data-index="key" :data-validation-message="item.name+'必选'">
						            <view :class="'name ' + ((province_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{(province_value[key] == null) ? default_province : (((province_list[key][province_value[key]] || null) == null) ? default_province : province_list[key][province_value[key]]['name'])}}</view>
						        </picker>
						    </view>
						    <view class="section fl">
						        <picker v-if="(city_list[key] || null) != null" :name="'city_'+item.sid+'_'+item.type+'_'+item.id" @change="select_city_event" :value="city_value[key]" :range="city_list[key]" range-key="name" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :data-index="key">
						            <view :class="'name ' + ((city_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{((city_list[key][city_value[key]] || null) == null) ? default_city : city_list[key][city_value[key]]['name']}}</view>
						        </picker>
						        <text v-else class="cr-grey" @tap="region_select_error_event" data-value="请先选择省份" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :data-index="key">请先选择省份</text>
						    </view>
						    <view class="section fl">
						        <picker v-if="(county_list[key] || null) != null" :name="'county_'+item.sid+'_'+item.type+'_'+item.id" @change="select_county_event" :value="county_value[key]" :range="county_list[key]" range-key="name" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :data-index="key">
						            <view :class="'name ' + ((county_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{((county_list[key][county_value[key]] || null) == null) ? default_county : county_list[key][county_value[key]]['name']}}</view>
						        </picker>
						        <text v-else class="cr-grey" @tap="region_select_error_event" data-value="请先选择城市" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :data-index="key">请先选择城市</text>
						    </view>
						</view>
					</block>
					<!--地址选择-->
					<block v-if="item.type == 13">
						<view class="pr" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :value="item.moren" @tap="choose_location_event" :data-lng="item.jingweidu_lng" :data-lat="item.jingweidu_lat" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength">
							<input type="text" :placeholder="item.tishi_text" :name="'input_'+item.sid+'_'+item.type+'_'+item.id" :class="'form-item wh-auto yxformplus-item '+(yx_form_type == 1 ? 'margin-vertical-main' : '')" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-minlength="item.minlength" :data-maxlength="item.maxlength" :data-is_must="item.is_must" :value="item.moren" :data-lng="item.jingweidu_lng" :data-lat="item.jingweidu_lat" :data-validation-message="'请输入正确的'+item.name" :data-index="key" :maxlength="(item.maxlength == 0) ? -1 : item.maxlength">
							<view class="map-icon pa cp tc">
								<uni-icons type="location" size="20" color="#666"></uni-icons>
							</view>
						</view>
					</block>
					<!--级联--> 
					<block v-if="item.type == 140 && (item.jilian || null != null)">
						<view v-for="(lv,li) in item.jilian" :key="li" class="yxsection">
						    <!--<picker :name="'jilian_'+item.sid+'_'+item.type+'_'+item.id" @change="yxjilianselect" :value="yxxiala_value[key]" :range="item.xiala" range-key="name" :data-form-id="item.sid" :data-type-id="item.type" :data-field-id="item.id" :data-title="item.name" :data-value="item.moren" :data-is_must="item.is_must" :data-validation-message="item.name+'必选'" :data-index="key">
								<view :class="'name ' + ((yxxiala_value[key] == null) ? 'cr-grey' : 'cr-base' )">{{(yxxiala_value[key] == null) ? '请选择' : (((item.xiala[yxxiala_value[key]] || null) == null) ? item.default_value : item.xiala[yxxiala_value[key]]['name'])}}</view>
						    </picker>-->
						</view>
					</block>
				</view>
				<view v-if="yx_form_type == 0 && item.unit != ''" class="danwei">{{item.unit}}</view>
			</view>
			<!-- #ifdef APP-PLUS -->
			<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></yk-authpup>
			<!-- #endif -->
		</view>
	</view>
</template>

<script>
	const app = getApp();
	// #ifdef APP-PLUS
	import ykAuthpup from "@/components/yk-authpup/yk-authpup";
	// #endif
	import {system_base_info} from "@/common/js/common/common";
	var common_static_url = app.globalData.get_static_url('common');
	export default {
		data() {
			return {
				common_static_url: common_static_url,
				// 自定义表单插件
				plugins_mandi_data:null,
				plugins_yxformplus_data:null,
				goods_id:0,
				theme_color:'#fe6f04',
				province_list:[],
				city_list: [],
				county_list: [],
				province_id: [],
				city_id: [],
				county_id: [],
				default_province: "请选择省",
				default_city: "请选择市",
				default_county: "请选择区/县",
				province_value: [],
				city_value: [],
				county_value: [],
				yxfile:[],
				yxxiala:[],//下拉列表数据
				yxxiala_value:[],//下拉选中数据对应的数组序号
				editor_path_type:'',
				form_type:'goods',
				user_location_cache_key: app.globalData.data.cache_userlocation_key,
				chose_addr_flag:0,
				permissionID:'',
				peraction:'',
				yx_form_type: app.globalData.data.yxform_use_what_style || 0,
			}
		},
		components: {
			// #ifdef APP-PLUS
			ykAuthpup
			// #endif
		},
		// propIndex 特殊传值，其传来的是商品的ID，目前应用在下单页
		props: {
		    propData: {
		    	type: [Array,Object],
		    	default: []
		    },
			propMandi: {
				type: [Array,Object],
				default: null
			},
			propGoodsId:{
				type: [String,Number],
				default: 0
			},
			propEditorPath:{
				type: String,
				default: ''
			},
			propFormType:{
				type: String,
				default: 'goods'
			},
			propIndex:{
				type: Number,
				default: 0
			},
			propIndex2:{
				type: Number,
				default: 0
			},
			propFlag:{
				type: [String,Number],
				default: 0
			},
			propUrl: {
			    type: String,
			    default: app.globalData.get_request_url('save', 'index', 'yxformplus'),
			}
		},
		// 页面被展示
		created: function() {
		    system_base_info()
		    .then(data=>{
		    	this.init_config(data);
		    });
		},
		watch:{//--侦听此值有点达不到要求，取消该方法，改为从父组件调user_location_init初始化地址
			/*chose_addr_flag: {
				handler(newValue, oldValue) {console.log(oldValue,newValue);
					// 回调将会在侦听开始之后被立即调用
					if(newValue != oldValue && newValue == true){
						this.user_location_init();
					}
				},
				immediate: true,
				deep: true
			},*/
		},
		methods: {
			// 初始化配置
			init_config(datainfo) {
			    this.setData({
			        theme_color: (parseInt(datainfo.base.is_use_diy_color) == 1) ? (datainfo.base.diy_color_main || '#fe6f04') : (datainfo.base.theme_default_color || '#fe6f04'),
			    });
				
				var self = this;
				var data = this.$props.propData;
				var base = [];
				var plugins_yxformplus_data = [];
				plugins_yxformplus_data['data'] = data;
				plugins_yxformplus_data['base'] = base;
				this.plugins_yxformplus_data = plugins_yxformplus_data;
				this.plugins_mandi_data = this.$props.propMandi;
				this.goods_id = this.$props.propGoodsId;
				this.editor_path_type = this.$props.propEditorPath;
				this.form_type = this.$props.propFormType;
				
				// 调用地址数据
				this.get_province_list();
				
				// 赋值初始化地址ID
				if((this.plugins_yxformplus_data || null) != null && (this.plugins_yxformplus_data.data || null) != null){
					var temp_data_list= this.plugins_yxformplus_data.data;
					var temp_province = [];
					var temp_city = [];
					var temp_county = [];
					var i_arr = [];
					var temp_img_list = [];
					var img_t = [];
					var temp_picurl = [];
					var temp_xiala_list = [];
					for (var i in temp_data_list) {
						if(parseInt(temp_data_list[i]['type']) == 12){
							temp_province[i] = temp_data_list[i]['province'];
							temp_city[i] = temp_data_list[i]['city'];
							temp_county[i] = temp_data_list[i]['county'];
							
							i_arr.push(i);
						}else{
							temp_province[i] = [];
							temp_city[i] = [];
							temp_county[i] = [];
						}
						
						// 存储的附件
						temp_picurl = [];
						temp_img_list[i] = [];
						if((temp_data_list[i].picurl || null != null) && temp_data_list[i].picurl.length > 0){
							temp_picurl = temp_data_list[i].picurl;
							img_t = [];
							for (var j in temp_picurl) {
								img_t.push(temp_picurl[j]['images']);// 只保留远程路径，存为一个数组
							}
							temp_img_list[i] = img_t;
						}
						
						// 存储的下拉列表
						temp_xiala_list[i] = [];
						if((temp_data_list[i].xiala || null != null) && temp_data_list[i].xiala.length > 0){
							temp_xiala_list[i] = temp_data_list[i].xiala;
						}
					}
					this.setData({
					    province_id: temp_province,
					    city_id: temp_city,
					    county_id: temp_county,
						yxfile:temp_img_list,
						yxxiala:temp_xiala_list,
						yx_form_type: app.globalData.data.yxform_use_what_style
					});
					if(i_arr || null != null && i_arr.length > 0){
						i_arr.forEach((d, i) => {
						    // 获取城市、区县
						    self.get_city_list(d);
						    self.get_county_list(d);
						});
					}
				}
				// 半秒后初始化数据
				setTimeout(function() {
					self.get_region_data();
					self.get_xiala_data();
				}, 1200);
			},
			
			// 判断是否登录
			check_user_login(e){
				return app.globalData.get_user_info(this, 'yxblur', e);
			},
			
			// 选择地理位置
			choose_location_event(e) {
				var user = app.globalData.get_user_info(this, 'choose_location_event');
				if (user != false) {
					var lng = e.currentTarget.dataset.lng;
					var lat = e.currentTarget.dataset.lat;
					var str = '?from=tjform';//加上来源
					if(parseFloat(lng) > 0 && parseFloat(lat) > 0)
					{
						str += '&lng='+lng+'&lat='+lat;
					}
					uni.setStorageSync('adr_field_info', e);
					var self = this;
					
					// 如果父页面来是下单页
					if(parseInt(self.$props.propFlag) > 0){
						uni.setStorageSync('order_buy_xu', self.$props.propIndex);
						uni.setStorageSync('order_buy_xu2', self.$props.propIndex2);
					}
					
					setTimeout(function() {
						self.chose_addr_flag = 1;
						uni.navigateTo({
							url: '/pages/common/open-setting-location/open-setting-location'+str
						});
					}, 200);
				}
			},
			
			// 地址信息初始化
			user_location_init() {
				var self = this;
				uni.getStorage({
					key: 'adr_field_info',
					success: function (res) {
						// 获取选择的地址信息
						var result = uni.getStorageSync(self.user_location_cache_key) || null;
						var data = '';
						if (result != null) {
							data += ((result.name || null) != null) ? result.name+',' : '';
							data += ((result.address || null) != null) ? result.address+',' : '';
							data += ((result.longitude || null) != null) ? result.longitude+',' : '';
							data += ((result.latitude || null) != null) ? result.latitude : '';
							
							// 组装数据，保存
							var e = res.data;
							var detail = {};
							detail['value'] = data;
							e['detail'] = detail;
							self.PluginsyxformplusSave(e);
						}
					},
					complete: function (res) {
						uni.removeStorage({
						    key: 'adr_field_info'
						});
						uni.removeStorage({
						    key: self.user_location_cache_key
						});
						
						// 让父页面在保存了地址选择后，重新加载一把
						self.$emit('backtoeditischoseaddress');
					}
				});
			},
			
			// yxformplus ---------------------------- begin
			// 初始化时，整理已存的表单地址数据
			get_region_data(e){
				var self = this;
				var temp_province_list = [];
				if(this.plugins_yxformplus_data || null != null){
					var temp_data_list = this.plugins_yxformplus_data.data || null;
					if(temp_data_list != null){
						// 先初始化
						var temp_province_value = [];
						var temp_city_value = [];
						var temp_county_value = [];
						for (var i in temp_data_list) {
						    if (temp_province_value[i] == undefined) {
						        temp_province_value[i] = '';
						    }
							if (temp_city_value[i] == undefined) {
							    temp_city_value[i] = '';
							}
							if (temp_county_value[i] == undefined) {
							    temp_county_value[i] = '';
							}
						}
						this.setData({
						    province_value: temp_province_value,
						    city_value: temp_city_value,
						    county_value: temp_county_value
						});
						
						for (var i in temp_data_list) {
							if(parseInt(temp_data_list[i]['type']) == 12){
								self.init_region_value(i);
							}
						}
						console.log(this.province_value);
					}
				}
			},
			// 初始化时，整理已存的表单下拉数据
			get_xiala_data(e){
				var self = this;
				var temp_province_list = [];
				if(this.plugins_yxformplus_data || null != null){
					var temp_data_list = this.plugins_yxformplus_data.data || null;
					if(temp_data_list != null){
						// 先初始化yxxiala_value
						var temp_list = [];
						for (var i in temp_data_list) {
						    if (temp_list[i] == undefined) {
						        temp_list[i] = '';
						    }
						}
						this.setData({
						    yxxiala_value: temp_list,
						});
						
						for (var i in temp_data_list) {
							if(parseInt(temp_data_list[i]['type']) == 6){
								self.init_xiala_value(i);
							}
						}
					}
				}
			},
			
			// 单个操作时校验，校验通过修改moren字段(用于提交订单时整体遍历校验)，同时保存该字段
			yxblur(e){
				var is_must = e.currentTarget.dataset.is_must;
				var value = e.detail.value;
				var msg = e.currentTarget.dataset.validationMessage;
				var title = e.currentTarget.dataset.title;
				var type_id = e.currentTarget.dataset.typeId;
				var minlength = e.currentTarget.dataset.minlength;
				var maxlength = e.currentTarget.dataset.maxlength;
				var key = e.currentTarget.dataset.index;
				if(parseInt(is_must) == 1 && value === ''){
					app.globalData.showToast(msg || title+'不能为空');
					return false;
				}
				
				// 无论是否有值，焦点离开时候先保存到远程数据库
				this.PluginsyxformplusSave(e);
				
				if(value != ''){
					// 校验过了是否必填，再校验大小，在类型为货币金钱时需要，为整数时，也如此校验大小
					if(parseInt(type_id) == 11 || parseInt(type_id) == 3)
					{
						if((parseFloat(minlength) > parseFloat(value)) || (parseFloat(maxlength) < parseFloat(value))){
							app.globalData.showToast(msg || '金额输入不正确');
							return false;
						}
					} else {
						// 为文本时，单行文本，多行文本，看长度是否符合要求
						if(parseInt(minlength) > 0 && value.length < parseInt(minlength)){
							app.globalData.showToast(title+'长度不能小于'+minlength);
							return false;
						}
						if(parseInt(maxlength) > 0 && value.length > parseInt(maxlength)){
							app.globalData.showToast(title+'长度不能大于'+maxlength);
							return false;
						}
					}
				}
			},
			// 单选多选
			yxonclick(e){
				var is_must = e.currentTarget.dataset.is_must;
				var value = e.detail.value;
				var msg = e.currentTarget.dataset.validationMessage;
				var title = e.currentTarget.dataset.title;
				var type_id = e.currentTarget.dataset.typeId;
				if(parseInt(type_id)==5){
					value = value.join(",");//多选的值转化为字符串
				}
				if(parseInt(is_must) == 1){
					if(value === '')
					{
						app.globalData.showToast(msg || title+'必选');
						return false;
					}
				}
				e.detail.value = value;
				// 保存
				this.PluginsyxformplusSave(e);
			},
			// 下拉
			yxselect(e){
				var index = parseInt(e.detail.value) || 0;// 数组序号
				var key = e.currentTarget.dataset.index;//字段在总的字段列表集中的序号
				var value = null;
				if (index >= 0) {
				    var data = this.yxxiala[key][index];
					var temp_yxxiala_value = this.yxxiala_value;
					temp_yxxiala_value[key] = index;//选中的数组序号
					value = data.value;
				    this.setData({
				        yxxiala_value: temp_yxxiala_value,
				    });
				}
				var is_must = e.currentTarget.dataset.is_must;
				var msg = e.currentTarget.dataset.validationMessage;
				var title = e.currentTarget.dataset.title;
				var type_id = e.currentTarget.dataset.typeId;
				if(parseInt(is_must) == 1){
					if(value === '' || value == null)
					{
						app.globalData.showToast(msg || title+'必选');
						return false;
					}
				}
				e.detail.value = value;
				// 保存
				this.PluginsyxformplusSave(e);
				//console.log(this.yxxiala_value);
			},
			bindDateChange(e){
				var is_must = e.currentTarget.dataset.is_must;
				var value = e.detail.value;
				var msg = e.currentTarget.dataset.validationMessage;
				var title = e.currentTarget.dataset.title;
				if(parseInt(is_must) == 1){
					if(value === '')
					{
						app.globalData.showToast(msg || title+'不能为空');
						return false;
					}
				}
				
				if((this.plugins_mandi_data || null ) != null && this.plugins_mandi_data.length > 0 && value != ''){
					if((this.plugins_mandi_data.base.manti_time_fid || 0) != 0){
						if(parseInt(e.currentTarget.dataset.fieldId) == parseInt(this.plugins_mandi_data.base.manti_time_fid)){
							var day = 0;
							var dateTme = new Date();
							var Y = dateTme.getFullYear();
							var M = dateTme.getMonth() + 1 < 10 ? "0" + (dateTme.getMonth() + 1) : dateTme.getMonth() + 1;
							var D = dateTme.getDate() < 10 ? "0" + dateTme.getDate() : dateTme.getDate();
							var today = Y + "-" + M + "-" + D;
							
							// 距离今日多少天
							day = this.yxDateDiff(today,value);
							
							day = (parseInt(day) > 0) ? parseInt(day) : 1;//最小1，不能为负数
							
							// 改变数量
							if(isNaN(day)) {
							    day = this.goods.buy_min_number || 1;
							}
							this.goods_buy_number_func(day);
						}
					}
				}
				
				// 保存
				this.PluginsyxformplusSave(e);
			},
			
			// 整体遍历校验表单，校验通过则保存每个字段
			PluginsyxformplusCheck(init_type=''){
				var fail = 0;//console.log(this.plugins_yxformplus_data);
				if((this.plugins_yxformplus_data || null) != null)
				{
					var e = {};
					var currentTarget = {};
					var dataset = {};
					var detail = {};
					var msg = '';
					// 这里可以循环有默认值且未被改过的项 -- 待完成
					var lastform = this.plugins_yxformplus_data.data || null;
					if(lastform != null){
						for (var i in lastform) {
							var type_id = parseInt(lastform[i].type);
							var title = lastform[i].name;
							
							// 一个个的来获取值，并校验
							msg = title+'不能为空';
							if(type_id == 4 || type_id == 5 || type_id == 6 ||type_id == 7 || type_id == 8 || type_id == 12){
								msg = title+'必选';
							}else if(type_id == 9 || type_id == 10){
								msg = title+'必须上传';
							}else if(type_id == 11){
								msg = '请输入正确的'+title;
							}
							// 地址类
							if(type_id == 12 && parseInt(lastform[i].is_must) === 1){
								var sss = lastform[i].moren.split(",");
								if(parseInt(sss[0]) === 0 || parseInt(sss[1]) === 0 || parseInt(sss[2]) === 0){
									app.globalData.showToast(msg);
									fail++;
									break;
								}
							}else{
								if(parseInt(lastform[i].is_must) === 1 && lastform[i].moren == ''){console.log(333);
									app.globalData.showToast(msg);
									fail++;
									break;
								}
							}
							// 长度校验
							var value = lastform[i].moren;
							var minlength = lastform[i].minlength;
							var maxlength = lastform[i].maxlength;
							if(value != ''){
								// 校验过了是否必填，再校验大小，在类型为货币金钱时需要，为整数时，也如此校验大小
								if(type_id == 11 || type_id == 3)
								{
									// 数字和货币时候，这里比对的是值的大小，是否在范围内，前提是设置了范围
									if((parseFloat(minlength) > 0 && parseFloat(minlength) > parseFloat(value)) || (parseFloat(maxlength) > 0 && parseFloat(maxlength) < parseFloat(value))){
										app.globalData.showToast(msg || '金额输入不正确');
										fail++;
										break;
									}
								} else {
									// 为文本时，单行文本，多行文本，看长度是否符合要求
									if(parseInt(minlength) > 0 && value.length < parseInt(minlength)){
										app.globalData.showToast(title+'长度不能小于'+minlength);
										fail++;
										break;
									}
									if(parseInt(maxlength) > 0 && value.length > parseInt(maxlength)){
										app.globalData.showToast(title+'长度不能大于'+maxlength);
										fail++;
										break;
									}
								}
							}
							
							// 组装数据，保存，还需要在优化一个问题，就是当没有默认值，无选择的单选之类的时候，应该赋予一个基础默认值
							dataset['index'] = i;
							dataset['typeId'] = lastform[i].type;
							dataset['formId'] = lastform[i].sid;
							dataset['fieldId'] = lastform[i].id;
							dataset['title'] = lastform[i].name;
							currentTarget['dataset'] = dataset;
							e['currentTarget'] = currentTarget;
							
							detail['value'] = lastform[i].moren;
							e['detail'] = detail;
							console.log(e);
							this.PluginsyxformplusSave(e);
						}
					}
				}
				
				// 刷新父组件对应值，此为需要区分组件的专属判断
				if(parseInt(this.$props.propFlag) > 0){
					// 大于0，表明传值来源于需要区分组件的页面，如下单页，将单个组件的检测结果传回，父页面统一处理
					this.$emit('backtosubmitform', fail);
				}else{
					// 检测通过，调用页面的自定义方法
					if(fail == 0){
						this.$emit('backtosubmitform', init_type);
					}
				}
				return false;
			},
			
			// 整体遍历校验表单，校验通过则保存每个字段
			datacheck(init_type=''){
				if((this.plugins_yxformplus_data || null) != null)
				{
					var e = {};
					var currentTarget = {};
					var dataset = {};
					var detail = {};
					var msg = '';
					// 这里可以循环有默认值且未被改过的项 -- 待完成
					var lastform = this.plugins_yxformplus_data.data || null;
					if(lastform != null){
						for (var i in lastform) {
							var type_id = parseInt(lastform[i].type);
							var title = lastform[i].name;
							
							// 一个个的来获取值，并校验
							msg = title+'不能为空';
							if(type_id == 4 || type_id == 5 || type_id == 6 ||type_id == 7 || type_id == 8 || type_id == 12){
								msg = title+'必选';
							}else if(type_id == 9 || type_id == 10){
								msg = title+'必须上传';
							}else if(type_id == 11){
								msg = '请输入正确的'+title;
							}
							// 地址类
							if(type_id == 12 && parseInt(lastform[i].is_must) === 1){
								var sss = lastform[i].moren.split(",");
								if(parseInt(sss[0]) === 0 || parseInt(sss[1]) === 0 || parseInt(sss[2]) === 0){
									app.globalData.showToast(msg);
									return false;
									break;
								}
							}else{
								if(parseInt(lastform[i].is_must) === 1 && lastform[i].moren == ''){console.log(333);
									app.globalData.showToast(msg);
									return false;
									break;
								}
							}
							// 长度校验
							var value = lastform[i].moren;
							var minlength = lastform[i].minlength;
							var maxlength = lastform[i].maxlength;
							if(value != ''){
								// 校验过了是否必填，再校验大小，在类型为货币金钱时需要，为整数时，也如此校验大小
								if(type_id == 11 || type_id == 3)
								{
									// 数字和货币时候，这里比对的是值的大小，是否在范围内，前提是设置了范围
									if((parseFloat(minlength) > 0 && parseFloat(minlength) > parseFloat(value)) || (parseFloat(maxlength) > 0 && parseFloat(maxlength) < parseFloat(value))){
										app.globalData.showToast(msg || '金额输入不正确');
										return false;
										break;
									}
								} else {
									// 为文本时，单行文本，多行文本，看长度是否符合要求
									if(parseInt(minlength) > 0 && value.length < parseInt(minlength)){
										app.globalData.showToast(title+'长度不能小于'+minlength);
										return false;
										break;
									}
									if(parseInt(maxlength) > 0 && value.length > parseInt(maxlength)){
										app.globalData.showToast(title+'长度不能大于'+maxlength);
										return false;
										break;
									}
								}
							}
						}
					}
				}
				return true;
			},
			
			// 表单提交
			PluginsyxformplusSave(e){
				var self = this;
				if(!app.globalData.is_single_page_check()) {
				    return false;
				}
				var user = app.globalData.get_user_info(this, 'PluginsyxformplusSave', e);
				if (user != false) {
					var key = e.currentTarget.dataset.index;
					var type_id = e.currentTarget.dataset.typeId;
					var value = e.detail.value;
					var data = {
						"form_id": e.currentTarget.dataset.formId,
						"field_id": e.currentTarget.dataset.fieldId,
						"type_id": type_id,
						"goods_id":this.goods_id,
						"form_type":this.form_type,
						"title": e.currentTarget.dataset.title,
						"content": value,
						"nowkey": key
					};
					
					/*uni.showLoading({
						title: '处理中...'
					});*/
					uni.request({
						url: this.propUrl,
						method: 'POST',
						data: data,
						dataType: 'json',
						success: res => {console.log(res);
							//uni.hideLoading();
							if (res.data.code == 0) {
								// 成功保存到服务器后，修改本地moren字段
								var temp_data = self.plugins_yxformplus_data || null;
								
								temp_data.data[key]['moren'] = value;
								self.setData({
									plugins_yxformplus_data: temp_data
								});
								
								// 刷新父组件对应值
								if(parseInt(self.$props.propFlag) > 0){
									// 大于0，表明传值来源于需要区分组件的页面，如下单页
									var chuanzhi = {};
									chuanzhi['xu'] = self.$props.propIndex;
									chuanzhi['xu2'] = self.$props.propIndex2;
									chuanzhi['data'] = temp_data.data;
									self.$emit('backtoupdate', chuanzhi);
								}else{
									self.$emit('backtoupdate', temp_data.data);
								}
								console.log(temp_data.data);
								
								// 如果参数含有需要重置的标识，则让父页面刷新一下
								if((e.is_re_load || null) != null)
								{
									// 让父页面在保存了地址选择后，重新加载一把，上面已经进行了推送加载，无须再执行这里
									//self.$emit('backtoeditischoseaddress');
								}
							}else if(res.data.code == -222){
								// 前台有登录信息，但后台登录的session已经被清除，此时重新授权
								// 用户登录缓存
								uni.removeStorageSync(app.globalData.data.cache_user_login_key);
								// 用户信息缓存
								uni.removeStorageSync(app.globalData.data.cache_user_info_key);
								// 重新保存
								uni.setStorageSync('temp_second_save_formdata_data', res.data.data);
								setTimeout(function() {
									self.second_save_formdata();
								}, 500);
							} else {
								app.globalData.showToast(res.data.msg);
							}
						},
						fail: () => {
							//uni.hideLoading();
							app.globalData.showToast(this.$t('common.internet_error_tips'));
						}
					});
				}
			},
			
			// 返回未登录结果，重新授权后自动二次保存
			second_save_formdata(){
				var self = this;
				var user = app.globalData.get_user_info(this, 'second_save_formdata');
				if (user != false) {
					var data = uni.getStorageSync('temp_second_save_formdata_data') || null;
					if(data != null){
						uni.request({
							url: app.globalData.get_request_url('save', 'index', 'yxformplus'),
							method: 'POST',
							data: data,
							dataType: 'json',
							success: res => {console.log(res);
								uni.removeStorageSync('temp_second_save_formdata_data');
								if (res.data.code == 0) {
									// 成功保存到服务器后，修改本地moren字段
									var temp_data = self.plugins_yxformplus_data || null;
									
									temp_data.data[data.nowkey]['moren'] = data.content;
									self.setData({
										plugins_yxformplus_data: temp_data
									});
									
									// 刷新父组件对应值
									if(parseInt(self.$props.propFlag) > 0){
										// 大于0，表明传值来源于需要区分组件的页面，如下单页
										var chuanzhi = {};
										chuanzhi['xu'] = self.$props.propIndex;
										chuanzhi['xu2'] = self.$props.propIndex2;
										chuanzhi['data'] = temp_data.data;
										self.$emit('backtoupdate', chuanzhi);
									}else{
										self.$emit('backtoupdate', temp_data.data);
									}
								} else {
									app.globalData.showToast(res.data.msg);
								}
							},
							fail: () => {
								uni.hideLoading();
								app.globalData.showToast(this.$t('common.internet_error_tips'));
							}
						});
					}
				}
			},
			
			// 地区数据初始化
			init_region_value(i) {
				var temp_province_value = this.province_value;
				var temp_city_value = this.city_value;
				var temp_county_value = this.county_value;
				temp_province_value[i] = this.get_region_value("province_list", "province_id",i);
				temp_city_value[i] = this.get_region_value("city_list", "city_id",i);
				temp_county_value[i] = this.get_region_value("county_list", "county_id",i);
			    this.setData({
			        province_value: temp_province_value,
			        city_value: temp_city_value,
			        county_value: temp_county_value
			    });
			},
			// 下拉数据初始化
			init_xiala_value(i) {
				var temp_xiala_value = this.yxxiala_value;// 下拉对应所在数组中的序号
				var data = this.plugins_yxformplus_data.data[i].xiala || null;
				var data_id = this.plugins_yxformplus_data.data[i].moren || 0;
				var value = null;
				if(data != null){
					data.forEach((d, i) => {
					    if (d.value == data_id) {
					        value = i;
					        return false;
					    }
					});
				}
				temp_xiala_value[i] = value;
			    this.setData({
			        yxxiala_value: temp_xiala_value
			    });
			},
			
			// 地区初始化匹配索引
			get_region_value(list, id, i) {
			    var data = this[list][i];
			    var data_id = this[id][i];
			    var value = null;
			    data.forEach((d, i) => {
			        if (d.id == data_id) {
			            value = i;
			            return false;
			        }
			    });
			    return value;
			},
			
			// 获取省份
			get_province_list() {
			    uni.request({
			        url: app.globalData.get_request_url("index", "region"),
			        method: 'POST',
			        data: {},
			        dataType: 'json',
			        success: res => {
			            if (res.data.code == 0) {
			                var data = res.data.data;
							// 给省份自动赋予省份全值
							var temp_province_list = [];
							if(this.plugins_yxformplus_data || null != null){
								var temp_data_list = this.plugins_yxformplus_data.data || null;
								if(temp_data_list != null){
									for (var i in temp_data_list) {
										if(parseInt(temp_data_list[i]['type']) == 12){
											temp_province_list[i] = data;
										}else{
											temp_province_list[i] = [];
										}
									}
								}
							}
			                this.setData({
			                    province_list: temp_province_list
			                });
			            } else {
			                app.globalData.showToast(res.data.msg);
			            }
			        },
			        fail: () => {
			            app.globalData.showToast("省份获取失败");
			        }
			    });
			},
			
			// 获取市
			get_city_list(i) {
				var self = this;
			    if (this.province_id[i]) {
			        uni.request({
			            url: app.globalData.get_request_url("index", "region"),
			            method: 'POST',
			            data: {
			                pid: this.province_id[i]
			            },
			            dataType: 'json',
			            success: res => {
			                if (res.data.code == 0) {
			                    var data = res.data.data;
								var temp_city_list = [];
								if(this.plugins_yxformplus_data || null != null){
									var temp_data_list = this.plugins_yxformplus_data.data || null;
									if(temp_data_list != null){
										for (var ii in temp_data_list) {
											if(parseInt(i) === parseInt(ii)){
												temp_city_list[ii] = data;
											}else{
												if((self.city_list[ii] || null != null) && self.city_list[ii].length > 0){
													temp_city_list[ii] = self.city_list[ii];
												}else{
													temp_city_list[ii] = [];
												}
											}
										}
									}
								}
			                    this.setData({
			                        city_list: temp_city_list
			                    });
			                } else {
			                    app.globalData.showToast(res.data.msg);
			                }
			            },
			            fail: () => {
			                app.globalData.showToast("城市获取失败");
			            }
			        });
			    }
			},
			
			// 获取区/县
			get_county_list(i) {
				var self = this;
			    if (this.city_id[i]) {
			        // 加载loding
			        uni.request({
			            url: app.globalData.get_request_url("index", "region"),
			            method: 'POST',
			            data: {
			                pid: this.city_id[i]
			            },
			            dataType: 'json',
			            success: res => {
			                if (res.data.code == 0) {
			                    var data = res.data.data;
								var temp_county_list = [];
								if(this.plugins_yxformplus_data || null != null){
									var temp_data_list = this.plugins_yxformplus_data.data || null;
									if(temp_data_list != null){
										for (var ii in temp_data_list) {
											if(parseInt(i) === parseInt(ii)){
												temp_county_list[ii] = data;
											}else{
												if((self.county_list[ii] || null != null) && self.county_list[ii].length > 0){
													temp_county_list[ii] = self.county_list[ii];
												}else{
													temp_county_list[ii] = [];
												}
											}
										}
									}
								}
			                    this.setData({
			                        county_list: temp_county_list
			                    });
			                } else {
			                    app.globalData.showToast(res.data.msg);
			                }
			            },
			            fail: () => {
			                app.globalData.showToast("区/县获取失败");
			            }
			        });
			    }
			},
			
			// 省份事件
			select_province_event(e) {
			    var index = e.detail.value || 0;// 数组序号
				var key = e.currentTarget.dataset.index;//字段在总的字段列表集中的序号
			    if (index >= 0) {
			        var data = this.province_list[key][index];
					var temp_province_value = this.province_value;
					temp_province_value[key] = index;
					var temp_province_id = this.province_id;
					temp_province_id[key] = data.id;
					var temp_city_value = this.city_value;
					temp_city_value[key] = [];
					var temp_county_value = this.county_value;
					temp_county_value[key] = [];
					var temp_city_id = this.city_id;
					temp_city_id[key] = [];
					var temp_county_id = this.county_id;
					temp_county_id[key] = [];
			        this.setData({
			            province_value: temp_province_value,
			            province_id: temp_province_id,
						city_value: temp_city_value,
						county_value: temp_county_value,
						city_id: temp_city_id,
						county_id: temp_county_id
			        });
			        this.get_city_list(key);
					
					// 选中省份后，保存一下，组装省市区字符串
					e.detail.value = data.id+',0,0';
					// 保存
					this.PluginsyxformplusSave(e);
			    }
			},
			
			// 市事件
			select_city_event(e) {
			    var index = e.detail.value || 0;
				var key = e.currentTarget.dataset.index;
			    if (index >= 0) {
			        var data = this.city_list[key][index];
					var temp_city_value = this.city_value;
					temp_city_value[key] = index;
					var temp_city_id = this.city_id;
					temp_city_id[key] = data.id;
					var temp_county_value = this.county_value;
					temp_county_value[key] = [];
					var temp_county_id = this.county_id;
					temp_county_id[key] = [];
			        this.setData({
			            city_value: temp_city_value,
			            city_id: temp_city_id,
			            county_value: temp_county_value,
			            county_id: temp_county_id
			        });
			        this.get_county_list(key);
					
					// 选中省份后，保存一下，组装省市区字符串
					e.detail.value = this.province_id[key]+','+data.id+',0';
					// 保存
					this.PluginsyxformplusSave(e);
			    }
			},
			
			// 区/县事件
			select_county_event(e) {
			    var index = e.detail.value || 0;
				var key = e.currentTarget.dataset.index;
			    if (index >= 0) {
			        var data = this.county_list[key][index];
					var temp_county_value = this.county_value;
					temp_county_value[key] = index;
					var temp_county_id = this.county_id;
					temp_county_id[key] = data.id;
			        this.setData({
			            county_value: temp_county_value,
			            county_id: temp_county_id
			        });
					
					// 选中省份后，保存一下，组装省市区字符串
					e.detail.value = this.province_id[key]+','+this.city_id[key]+','+data.id;
					
					// 需要父页面重新加载
					e.is_re_load = 1;
					
					// 保存
					this.PluginsyxformplusSave(e);
			    }
			},
			
			// 省市区未按照顺序选择提示
			region_select_error_event(e) {
			    var value = e.currentTarget.dataset.value || null;
			    if (value != null) {
			        app.globalData.showToast(value);
			    }
			},
			
			// 上传图片预览
			upload_show_event(e) {
			    var index = e.currentTarget.dataset.index;
			    var ix = e.currentTarget.dataset.ix;
				if(app.globalData.is_android())
				{
					var self = this;
					uni.previewImage({
					    current: self.yxfile[index][ix],
					    urls: self.yxfile[index],
						longPressActions: {
							itemList: [self.$t('fengcheche.fcctips.t9')],
							success: function(data) {
								// 先关闭预览，否则会遮挡上方权限提醒
								uni.closePreviewImage();
								self.peraction = 'previewImage';
								self.permissionID = 'WRITE_EXTERNAL_STORAGE';
								setTimeout(()=>{
									self.$refs['authpup'].open(self.yxfile[index][ix]);
								},500);
							},
							fail: function(err) {
								console.log(err.errMsg);
							}
						}
					});
				}else{
					uni.previewImage({
					    current: this.yxfile[index][ix],
					    urls: this.yxfile[index]
					});
				}
			},
			
			// #ifdef APP-PLUS
			//用户授权权限后的回调
			changeAuth(e){
				if(this.permissionID == 'WRITE_EXTERNAL_STORAGE')
				{
					if(this.peraction == 'previewImage')
					{
						app.globalData.save_image_by_url(e);
					}else{
						this.file_upload_event_true(e);
					}
				}else{
					// 第一次是摄像头返回，再返回是相册权限，然后才继续执行
					this.peraction = 'fileupload';
					this.permissionID = 'WRITE_EXTERNAL_STORAGE';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}
			},
			// #endif
			
			// 图片删除
			upload_delete_event(e) {
			    var index = e.currentTarget.dataset.index;
			    var ix = e.currentTarget.dataset.ix;
			    var self = this;
			    uni.showModal({
			        title: this.$t('common.warm_tips'),
			        content: this.$t('recommend-list.recommend-list.54d418'),
			        confirmText: this.$t('common.confirm'),
			        cancelText: this.$t('recommend-list.recommend-list.w9460o'),
			        success(res) {
			            if (res.confirm) {
							// 可做远程删除，结果成功后执行下面的本地删除
			                var list = self.yxfile;
			                list[index].splice(ix, 1);
			                self.setData({
			                    yxfile: list
			                });
			            }
			        }
			    });
			},
			
			// 文件上传
			file_upload_event(e) {
				if(app.globalData.is_android())
				{
					this.permissionID = 'CAMERA';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}else{
					this.file_upload_event_true(e);
				}
			},
			
			file_upload_event_true(e)
			{
				if(!app.globalData.is_single_page_check()) {
				    return false;
				}
				var user = app.globalData.get_user_info(this, 'file_upload_event_true', e);
				if (user != false) {
					// 数据初始化
					var index = e.currentTarget.dataset.index;
					var temp_list = this.yxfile;
					var maxnum = parseInt(e.currentTarget.dataset.maxNumber);
					var file_type = e.currentTarget.dataset.file_type;
					// 处理上传文件
					var self = this;
					if(file_type=='images'){
						uni.chooseImage({
							count: maxnum,
							success(res) {
								var success = 0;
								var fail = 0;
								var length = res.tempFilePaths.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length,maxnum,file_type,e);
							}
						});
					}else if(file_type=='video'){
						uni.chooseVideo({
							success(res) {
								var success = 0;
								var fail = 0;
								var length = 1;//res.tempFilePath.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePath, success, fail, count, length,maxnum,file_type,e);
							}
						});
					}else{
						// #ifdef H5
						uni.chooseFile({
							//count: maxnum,
							success(res) {console.log(res);
								var success = 0;
								var fail = 0;
								var length = res.tempFilePaths.length;
								var count = 0;
								self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length,maxnum,file_type,e);
							}
						});
						// #endif
						// #ifdef MP-WEIXIN
						//从微信聊天会话中选择文件
						wx.chooseMessageFile({
							count: maxnum,
							type:'file',
							success(res) {console.log(res);
								var success = 0;
								var fail = 0;
								var length = res.tempFiles.length;
								var count = 0;
								// 微信这个tempFiles是对象，需要给其中的路径取出来，组装成新的数组，以适配upload_one_by_one方法
								var temp_files = [];
								for (var ii in res.tempFiles) {
									temp_files[ii] = res.tempFiles[ii].path;
								}
								self.upload_one_by_one(index, temp_files, success, fail, count, length,maxnum,file_type,e);
							}
						});
						// #endif
						// #ifndef H5 || MP-WEIXIN
						app.globalData.showToast('当前端不支持文件上传');
						// #endif
					}
				}
			},
			
			// 采用递归的方式上传多张
			upload_one_by_one(index, img_paths, success, fail, count, length,maxnum,file_type,e) {
			    var self = this;
				var file_action = '';
				if(file_type=='images'){
					file_action = 'uploadimage';
				}else if(file_type=='video'){
					file_action = 'uploadvideo';
				}else{
					file_action = 'uploadfile';
				}
			    if ((self.yxfile[index] || null) == null || self.yxfile[index].length < maxnum) {
					uni.showLoading({
					    title: '上传中...'
					});
			        uni.uploadFile({
			            url: app.globalData.get_request_url("index", "ueditor"),
			            filePath: (file_type=='video') ? img_paths : img_paths[count],
			            name: 'upfile',
			            formData: {
			                action: file_action,
			                path_type: self.editor_path_type
			            },
			            success: function(res) {
							uni.hideLoading();
			                success++;
			                if (res.statusCode == 200) {
			                    var data = typeof res.data == 'object' ? res.data : JSON.parse(res.data);
			                    if (data.code == 0 && (data.data.url || null) != null) {
			                        var list = self.yxfile;
			                        if ((list[index] || null) == null) {
			                            list[index] = [];
			                        }
			                        list[index].push(data.data.url);
			                        self.setData({
			                            yxfile: list
			                        });
									// 改写当前结果，保存
									var lastr = '';
									for (var ii in list[index]) {
										if(lastr == ''){
											lastr = list[index][ii];
										}else{
											lastr += ','+list[index][ii];
										}
									}
									e.detail.value = lastr;
									// 保存
									self.PluginsyxformplusSave(e);
			                    } else {
			                        app.globalData.showToast(data.msg);
			                    }
			                }
			            },
			            fail: function(res) {
			                fail++;
			            },
			            complete: function(res) {
			                count++;
			                // 下一张
			                if (count >= length) {
			                    // 上传完毕，作一下提示
			                    //app.showToast('上传成功' + success +'张', 'success');
			                } else {
			                    // 递归调用，上传下一张  稍微延迟一下
								setTimeout(function() {
								    self.upload_one_by_one(index, img_paths, success, fail, count, length,maxnum,file_type,e);
								}, 1000);
			                }
			            }
			        });
			    }
			}
			// yxformplus------------------------end
		}
	}
</script>

<style>
/*自定义表单*/
.c_b{clear:both;}
.plugins-yxformplus0{font-size:28rpx;padding:0 0rpx;}
.plugins-yxformplus0 .yxformplus-item,.plugins-yxformplus0 .yxsection{box-sizing: border-box;min-height:65rpx;display: block;line-height: 65rpx;padding:0 15rpx;}
.plugins-yxformplus0 .item{padding:15rpx 0rpx;border-bottom: 1px solid #fafafa;}
.plugins-yxformplus0 .item:last-child{border:none;}
.plugins-yxformplus0 .item .title{font-size:28rpx;padding-right:15rpx;line-height: 65rpx;min-width: 180rpx;}
.plugins-yxformplus0 .item .title text{font-weight: normal;font-size:22rpx;color:#999;}
.plugins-yxformplus0 .item .danwei{line-height: 65rpx;}
.plugins-yxformplus0 textarea.yxformplus-item{min-height: 130rpx;padding:15rpx;font-size:28rpx;line-height:35rpx;}
.plugins-yxformplus0 .spec{padding-right:0rpx;justify-content: flex-end;text-align: right;}
.plugins-yxformplus0 .spec.spec2{text-align: left;}
.plugins-yxformplus0 .uni-list{padding-top:0rpx;line-height: 65rpx;}
.plugins-yxformplus0 .yxradio{margin-right:20rpx;}
.plugins-yxformplus0 .yxcheckbox{height:45rpx;margin-right:20rpx;margin-bottom: 15rpx;display: inline-block;}
.plugins-yxformplus0 .tj-input{min-height:65rpx;}		   
.plugins-yxformplus0 .yxfile{background: #fff;}
.plugins-yxformplus0 .form-upload-data image,.plugins-yxformplus0 .form-upload-data video,.plugins-yxformplus0 .form-upload-data .wendangbox {
    width: 100rpx;
    height: 100rpx;
}
.plugins-yxformplus0 .form-upload-data .wendangbox{border:1px solid #ccc;line-height: 100rpx;text-align: center;overflow: hidden;}
.plugins-yxformplus0 .upload-icon {
    width: 110rpx;
    height: 110rpx;
	border:1px solid #ddd;
	border-radius: 15rpx;
}
.plugins-yxformplus0 .form-upload-data .picitem{position: relative;margin-right:10rpx;}
.plugins-yxformplus0 .form-upload-data .delete-icon {
    position: absolute;
    top: -6rpx;
    right: -6rpx;
    color: #e5e5e5;
    background-color: #d9534f;
    padding: 5rpx 18rpx;
    font-size: 26rpx;
    border: 1px solid #eee;
    border-radius: 50%;
    line-height: 38rpx;
    z-index: 1;
}
.plugins-yxformplus0 .select-address {
    box-sizing: border-box;
    height: 65rpx;
    line-height: 65rpx;
    padding: 0 10rpx;
	width:90%;
	float: right;
}
.plugins-yxformplus0 .select-address .section {
    width: 33.33%;
    box-sizing: border-box;background: #fff;
}
.plugins-yxformplus0 .select-address .section:not(:first-child) {
    padding: 0 5rpx;
}
.plugins-yxformplus0 .map-icon{right:10rpx;top:10rpx;}
.plugins-yxformplus0 .arrow-right{margin-right:0;margin-left:10rpx;}

/*自定义表单*/
.plugins-yxformplus1{font-size:28rpx;padding:0 0rpx;}
.plugins-yxformplus1 .yxformplus-item,.plugins-yxformplus1 .yxsection{margin-top:20rpx;box-sizing: border-box;border:1px solid #ccc;height:45rpx;border-radius: 5px;min-height:65rpx;display: block;line-height: 65rpx;padding:0 15rpx;background: #fff;}
.plugins-yxformplus1 .item{padding:15rpx 0 15rpx;}
.plugins-yxformplus1 .item .title{font-weight: bold;font-size:30rpx;}
.plugins-yxformplus1 .item .title text{font-weight: normal;font-size:22rpx;color:#999;}
.plugins-yxformplus1 .arrow-right{display:none;}
.plugins-yxformplus1 textarea.yxformplus-item{min-height: 130rpx;}
.plugins-yxformplus1 .spec{padding-right:0rpx;}
.plugins-yxformplus1 .uni-list{padding-top:20rpx;}
.plugins-yxformplus1 .yxradio{margin-right:20rpx;}
.plugins-yxformplus1 .yxcheckbox{height:45rpx;margin-right:20rpx;margin-bottom: 15rpx;display: inline-block;}
.plugins-yxformplus1 .tj-input{min-height:65rpx;}				   
.plugins-yxformplus1 .yxfile{margin-top:20rpx;background: #fff;}
.plugins-yxformplus1 .form-upload-data image,.plugins-yxformplus1 .form-upload-data video,.plugins-yxformplus1 .form-upload-data .wendangbox {
    width: 100rpx;
    height: 100rpx;
}
.plugins-yxformplus1 .form-upload-data .wendangbox{border:1px solid #ccc;line-height: 100rpx;text-align: center;overflow: hidden;}
.plugins-yxformplus1 .upload-icon {
    width: 110rpx;
    height: 110rpx;
	border:1px solid #ddd;
	border-radius: 15rpx;
}
.plugins-yxformplus1 .form-upload-data .picitem{position: relative;margin-right:10rpx;}
.plugins-yxformplus1 .form-upload-data .delete-icon {
    position: absolute;
    top: -6rpx;
    right: -6rpx;
    color: #e5e5e5;
    background-color: #d9534f;
    padding: 5rpx 18rpx;
    font-size: 26rpx;
    border: 1px solid #eee;
    border-radius: 50%;
    line-height: 38rpx;
    z-index: 1;
}
.plugins-yxformplus1 .select-address {
    box-sizing: border-box;
    height: 70rpx;
    line-height: 70rpx;
    padding: 0 10rpx;
}
.plugins-yxformplus1 .select-address .section {
    width: 33.33%;
    box-sizing: border-box;background: #fff;
}
.plugins-yxformplus1 .select-address .section:not(:first-child) {
    padding: 0 5rpx;
}
.plugins-yxformplus1 .map-icon{right:10rpx;top:10rpx;}
</style>
